package com.zuihai.app.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.zuihai.app.mvp.contract.HomeContract;
import com.zuihai.app.mvp.model.api.service.HomeService;
import com.zuihai.app.mvp.model.entity.HomeBanner;
import com.zuihai.app.mvp.model.entity.BaseJson;

import javax.inject.Inject;

import rx.Observable;

/**
 * Created by Administrator on 2017/6/1 0001.
 */

@FragmentScope
public class HomeModel extends BaseModel implements HomeContract.Model {
    private Gson mGson;
    private Application mApplication;
    private HomeService mHomeService;

    @Inject
    public HomeModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
        mHomeService = repositoryManager.obtainRetrofitService(HomeService.class);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseJson<HomeBanner>> requestBanner() {
        return mHomeService.requestBanner();
    }
}
